﻿using Microsoft.Xna.Framework.Graphics;
using xEngine.Rendering;

namespace xEngine.Utils
{
    public static class Utils
    {
        public static string UppercaseFirst(string s)
        {
            if (string.IsNullOrEmpty(s))
                return string.Empty;

            return char.ToUpper(s[0]) + s.Substring(1);
        }

        public static RenderTarget2D CloneRenderTarget(RenderTarget2D source)
        {
            return new RenderTarget2D(source.GraphicsDevice, source.Width, source.Height, source.LevelCount > 1,
                                      source.Format, source.DepthStencilFormat, source.MultiSampleCount, source.RenderTargetUsage);
        }
        public static RenderTarget2D CreateMainRenderTarget()
        {
            return CreateMainRenderTarget(true);
        }
        public static RenderTarget2D CreateMainRenderTarget(bool aa)
        {
            return new RenderTarget2D(RenderManager.Device,
                                      RenderManager.Device.PresentationParameters.BackBufferWidth,
                                      RenderManager.Device.PresentationParameters.BackBufferHeight,
                                      false,
                                      RenderManager.Device.PresentationParameters.BackBufferFormat,
                                      RenderManager.Device.PresentationParameters.DepthStencilFormat,
                                      aa ? RenderManager.Device.PresentationParameters.MultiSampleCount : 0,
                                      RenderTargetUsage.PreserveContents);
        }
    }
}
